package com.mudalov.rec.dao.model.user;

import com.mudalov.rec.dao.interfaces.IClonable;
import java.io.Serializable;

public class Role implements Serializable, IClonable<Role> {
	
	private static final long serialVersionUID = -1077083185527973202L;

    public Role getClone() {
        Role clone = new Role();
        clone.setId(this.getId());
        clone.setName(this.getName());
        return clone;
    }

	public static enum Type {STUDENT, TEACHER, ADMIN}

	private Long id;
	
	private String name;
	
	public Role() {}
	
	public Role(String name) {
		this.name = name;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Role))
			return false;
		Role other = (Role) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
